package Text5;

import java.util.*;

public class Main {
    //    给定一个 N×M的矩阵 A，请你统计有多少个子矩阵 (最小 1×1，最大 N×M)
//    满足子矩阵中所有数的和不超过给定的整数 K?
    static int N = 510;
    static int[][] a = new int[N][N];
    static int[][] s = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = in.nextInt();
                s[i][j] = s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1] + a[i][j];
            }
        }
        long res=0;
        for (int i = 1; i <=n ; i++) {
            for (int j = i; j <=n ; j++) {
                for (int r = 1,l=1; r <=m; r++) {
                    while (l<=r&&s[j][r]-s[i-1][r]-s[j][l-1]+s[i-1][l-1]>k){
                        l++;
                    }
                    if(l<=r){
                        res+=r-l+1;
                    }
                }
            }
        }
        System.out.println(res);
    }
}

